import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import LoginView from '../views/LoginView.vue'
import VideoView from '../views/VideoView.vue'
import StoreDetailView from '../views/StoreDetailView.vue'
import AddressManageView from '../views/AddressManageView.vue'
import AddressEditView from '../views/AddressEditView.vue'
import ProfileSettingsView from '../views/ProfileSettingsView.vue'
import VideoUploadView from '../views/VideoUploadView.vue'
import StoreListView from '../views/StoreListView.vue'
import StoreNearByView from '../views/StoreNearByView.vue'
import ProfileView from '../views/ProfileView.vue'
import ProductListView from '../views/ProductListView.vue'
import ProductDetailView from '../views/ProductDetailView.vue'
import SplashView from '../views/SplashView.vue'
import VideoPlayerView from '../views/VideoPlayerView.vue'
import OrdersView from '../views/OrdersView.vue'
import OrderLogisticsView from '../views/OrderLogisticsView.vue'
import OrderReviewView from '../views/OrderReviewView.vue'
import FavoritiesView from '../views/Favorities.vue'
import Navigation from '../views/Navigation.vue'
import CheckoutView from '../views/CheckoutView.vue'
import PaymentView from '../views/PaymentView.vue'
import HelpCenterView from '../views/HelpCenterView.vue'
import ProductListOfStoreView from '../views/ProductListOfStoreView.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/splash'
  },
  {
    path: '/splash',
    name: 'splash',
    component: SplashView
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/RegisterView.vue'),
    meta: {
      title: '注册',
      requiresAuth: false
    }
  },
  {
    path: '/reset-password',
    name: 'ResetPassword',
    component: () => import('../views/ResetPasswordView.vue'),
    meta: {
      title: '重置密码',
      requiresAuth: false
    }
  },
  {
    path: '/store/:id',
    name: 'StoreDetail',
    component: StoreDetailView
  },
  {
    path: '/video',
    name: 'video',
    component: VideoView
  },
  {
    path: '/video/upload',
    name: 'videoUpload',
    component: VideoUploadView
  },
  {
    path: '/videoPlayer/:id',
    name: 'videoPlayer',
    component: VideoPlayerView
  },
  {
    path: '/address',
    name: 'address',
    component: AddressManageView
  },
  {
    path: '/address/edit/:id',
    name: 'addressEdit',
    component: AddressEditView
  },
  {
    path: '/address/add',
    name: 'addressAdd',
    component: AddressEditView
  },
  {
    path: '/settings',
    name: 'settings',
    component: ProfileSettingsView
  },
  {
    path: '/store',
    name: 'store',
    component: StoreListView
  },
  {
    path: '/store/nearby',
    name: 'storeNearby',
    component: StoreNearByView
  },
  {
    path: '/profile',
    name: 'profile',
    component: ProfileView
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import(/* webpackChunkName: "cart" */ '../views/CartView.vue')
  },
  {
    path: '/orders',
    name: 'orders',
    component: OrdersView
  },
  {
    path: '/help',
    name: 'help',
    component: HelpCenterView
  },
  {
    path: '/store/product-list/:storeId/:categoryId',
    name: 'StoreProductList',
    component: ProductListView
  },
  {
    path: '/store/:storeId/products',
    name: 'StoreProductListAll',
    component: ProductListOfStoreView
  },
  {
    path: '/products',
    name: 'product-list',
    component: ProductListView
  },
  {
    path: '/product/:id',
    name: 'ProductDetail',
    component: ProductDetailView
  },
  {
    path: '/order/:id/logistics',
    name: 'orderLogistics',
    component: OrderLogisticsView
  },
  {
    path: '/review',
    name: 'orderReview',
    component: OrderReviewView
  },
  {
    path: '/favorites',
    name: 'favorites',
    component: FavoritiesView
  },
  {
    path: '/checkout',
    name: 'checkout',
    component: CheckoutView
  },
  {
    path: '/payment',
    name: 'payment',
    component: PaymentView
  },
  {
    path: '/navigation',
    name: 'Navigation',
    component: Navigation
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
